@echo off
:: echo ++[%0] [%*]
find ":[%1]" %~dpnx0 > nul && goto :[%1] || goto MAIN


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:MAIN 
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    setlocal

    if "%.hop%"=="" (
        (set .hop=%~dpnx0%)
        (set path=%~dp0;%path%)
        (set prompt=[HOP] %prompt%)
    )

    (set cmd=)
    (set bin=%~dp0bin)
    (set a=%1) & shift
    (set b=%1) & shift
    (set c=%1) & shift

    :parseloop
        if not "%~1"=="" ((set C=%C% %1) & shift & goto :parseloop)

    if "%cmd%"=="" if exist %bin%\%A%\%B%.bat (set args=%C%)
    if "%cmd%"=="" if exist %bin%\%A%\%B%.bat (set cmd=%A%\%B%)
    if "%cmd%"=="" if exist %bin%\%A%.bat     (set args=%B% %C%)
    if "%cmd%"=="" if exist %bin%\%A%.bat     (set cmd=%A%)
    if "%cmd%"==""                            (set args=%A% %B% %C%)

    (set a=)
    (set b=)
    (set c=)
    (set bin=)
    if "%cmd%"=="" (set _=%cmd% %args%) else (set _=%bin%\%cmd%.bat %args%)
    (set args=)
    %_%

    endlocal
    goto :eof


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:[] 
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    echo hop is here
    goto :eof


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:[--drop-one]
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    (set acc=%3)
    :droploop
        shift
        if not "%~3"=="" (set acc=%acc% %3)
        if not "%~3"=="" goto :droploop
    goto :eof


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:[--set]
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    if "%~2"=="" echo hop/--set: argument needed & goto :eof
    (set %2=%~3)
    goto :eof


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:[--report]
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    echo %hop.nest%: %~2
    goto :eof


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:[--welcome]
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    if not "%.hop%"=="" echo Welcome Grasshopper! & goto :eof
    setlocal
        color a0
        (set .hop=%~dpnx0%)
        (set prompt=[HOP] %prompt%)
        set path=%~dp0;%path%
        if "%~2"=="" echo Welcome Grasshopper!
        if "%~2"=="" call hop cmd /k
        if "%~2"=="" goto :goodbye
        %~2
        :goodbye
        color e2
        echo YOU MAY NOW CLOSE THIS WINDOW
        pause > nul
        goto :goodbye
        echo DONE
    endlocal
    goto :eof

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:[jude]
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    call %hopper.root%.\%1\%*
    goto :eof

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:[cojude]
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    setlocal
    (set dst=%hopper.root%\jude)
    (set src=/trunk)
    (set rev=HEAD)
    call %0 svn co https://judetheobscure.googlecode.com/svn%src% %dst% -r %rev%
    endlocal
    goto :eof
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:[svn]
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    call %~dp0bin\svn\%*
    goto :eof